/*  SSImportDuplicateAlertController.m
 *  MESLib
 * 
 * Copyright 2003-2009 Starline Software Ltd
 * 
 * This file is part of MESLib.
 * 
 * MESLib is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * MESLib is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with MESLib. If not, see <http://www.gnu.org/licenses/>.
 */
//  Created by Tobias Haughton on Tue Jul 22 2003.
//

#import "SSImportDuplicateAlertController.h"


@implementation SSImportDuplicateAlertController

+ (int)displayImportDuplicateAlert:(NSString *)string {
   static SSImportDuplicateAlertController *importDuplicateAlertController = nil;

   if(!importDuplicateAlertController) {
      importDuplicateAlertController = [[SSImportDuplicateAlertController allocWithZone:[self zone]] init];
   }

   [importDuplicateAlertController window]; //make sure the window is loaded so we can set the string
   [importDuplicateAlertController setDisplayText:string];
   [importDuplicateAlertController showWindow:self];

   return [importDuplicateAlertController result];
}

- (id)init {
   self = [super initWithWindowNibName:@"ImportDuplicatePanel"];
   if (self) {
      [self setWindowFrameAutosaveName:@"ImportDuplicatePanel"];
   }

   return self;
}

- (IBAction)showWindow:(id)sender
{
   //display our panel in a model session
   NSModalSession session;

   [self window];

   session = [NSApp beginModalSessionForWindow:[self window]];
   for (;;) {
      if ([NSApp runModalSession:session] != NSRunContinuesResponse)
         break;
   }
   
   [NSApp endModalSession:session];
}

- (IBAction)selection:(id)sender
{
   result = [sender tag];
   
   [NSApp stopModal];
   [self close];  
}

- (int)result
{
   return result;
}

- (void)setDisplayText:(NSString *)string
{
   [alertDisplayText setStringValue:string];
}


@end
